package com.ruoyi.project.xkx.school.controller;

import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.project.xkx.order.domain.ClassStudent;
import com.ruoyi.project.xkx.school.domain.XkxClassStudent;
import com.ruoyi.project.xkx.school.service.IXkxClassStudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/classStudent")
public class XkxClassStudentController {
  @Autowired
  private IXkxClassStudentService classStudentService;

  @GetMapping
  public AjaxResult getClassStudentData(Integer classId){
    List<XkxClassStudent> classStudent = classStudentService.getClassStudent(classId);
    return AjaxResult.success(classStudent);
  }
  @PutMapping
  public AjaxResult updateStudentClass(@RequestBody  XkxClassStudent classStudent){
    boolean b = classStudentService.updateById(classStudent);
    if (b==true){
      return AjaxResult.success();
    }else{
      return AjaxResult.error();
    }

  }
  @DeleteMapping("/{classStudentId}")
  public AjaxResult deleteStudentClass(@PathVariable Integer classStudentId){
    boolean b = classStudentService.removeById(classStudentId);
    if (b==true){
      return AjaxResult.success();
    }else{
      return AjaxResult.error();
    }

  }
}
